x86: Pickle domain in page_info into 32 bits.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 28 Jan 2009 17:40:01 +0000 (17:40 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 28 Jan 2009 17:40:01 +0000 (17:40 +0000)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/ia64/xen/domain.c
xen/arch/x86/domain.c
xen/common/domain.c
xen/include/asm-x86/mm.h
xen/include/xen/domain.h

index 52312fc969d782949a707dd7db292cf14eca7e69..b22304a1bb8579a65196ee9f3d59842ba0005cf8 100644 (file)
@@ -405,6 +405,16 @@ void relinquish_vcpu_resources(struct vcpu *v)
        kill_timer(&v->arch.hlt_timer);
 }
 
+struct domain *alloc_domain_struct(void)
+{
+    return xmalloc(struct domain);
+}
+
+void free_domain_struct(struct domain *d)
+{
+    xfree(d);
+}
+
 struct vcpu *alloc_vcpu_struct(void)
 {
        struct page_info *page;
index 1ee5482b96dcafc6ee6c8052d11cd5022f02c6d9..e6fc0454b25536f0f47f4abde5039c008fe7e8d9 100644 (file)
@@ -162,6 +162,25 @@ void dump_pageframe_info(struct domain *d)
     }
 }
 
+struct domain *alloc_domain_struct(void)
+{
+    struct domain *d;
+    /*
+     * We pack the MFN of the domain structure into a 32-bit field within
+     * the page_info structure. Hence the MEMF_bits() restriction.
+     */
+    d = alloc_xenheap_pages(
+        get_order_from_bytes(sizeof(*d)), MEMF_bits(32 + PAGE_SHIFT));
+    if ( d != NULL )
+        memset(d, 0, sizeof(*d));
+    return d;
+}
+
+void free_domain_struct(struct domain *d)
+{
+    free_xenheap_pages(d, get_order_from_bytes(sizeof(*d)));
+}
+
 struct vcpu *alloc_vcpu_struct(void)
 {
     struct vcpu *v;
index ab807bfbf864efb058e326ef33cf8cbc60bd6d31..5a5888e46a6461900c52547c229deeda2e09506c 100644 (file)
@@ -102,16 +102,6 @@ int current_domain_id(void)
     return current->domain->domain_id;
 }
 
-static struct domain *alloc_domain_struct(void)
-{
-    return xmalloc(struct domain);
-}
-
-static void free_domain_struct(struct domain *d)
-{
-    xfree(d);
-}
-
 static void __domain_finalise_shutdown(struct domain *d)
 {
     struct vcpu *v;
index 8c6fd64cca24b4cd7582d27445140d6638629ce1..7fa0bf98396049d5283f927bd31ccca94803411a 100644 (file)
@@ -31,7 +31,7 @@ struct page_info
         /* Page is in use: ((count_info & PGC_count_mask) != 0). */
         struct {
             /* Owner of this page (NULL if page is anonymous). */
-            unsigned long _domain; /* pickled format */
+            u32 _domain; /* pickled format */
             /* Type reference count and various PGT_xxx flags and fields. */
             unsigned long type_info;
         } inuse;
@@ -173,8 +173,11 @@ struct page_info
 /* OOS fixup entries */
 #define SHADOW_OOS_FIXUPS 2
 
-#define page_get_owner(_p)    ((struct domain *)(_p)->u.inuse._domain)
-#define page_set_owner(_p,_d) ((_p)->u.inuse._domain = (unsigned long)(_d))
+#define page_get_owner(_p)                                              \
+    ((struct domain *)((_p)->u.inuse._domain ?                          \
+                       mfn_to_virt((_p)->u.inuse._domain) : NULL))
+#define page_set_owner(_p,_d)                                           \
+    ((_p)->u.inuse._domain = (_d) ? virt_to_mfn(_d) : 0)
 
 #define maddr_get_owner(ma)   (page_get_owner(maddr_to_page((ma))))
 #define vaddr_get_owner(va)   (page_get_owner(virt_to_page((va))))
index cf82d07ea065aeeec40db3eff303273c28e737b6..65df554421e2a0d565a7c27af5bcb324276af9bd 100644 (file)
@@ -23,6 +23,10 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info);
  * Arch-specifics.
  */
 
+/* Allocate/free a domain structure. */
+struct domain *alloc_domain_struct(void);
+void free_domain_struct(struct domain *d);
+
 /* Allocate/free a VCPU structure. */
 struct vcpu *alloc_vcpu_struct(void);
 void free_vcpu_struct(struct vcpu *v);